﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		NotificationConfiguration.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            NotificationConfiguration.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 
using System;
using System.Net.Mail;
using System.Xml.Serialization;

namespace Dexter.Domain.Model {
	/// <summary>
	/// This class contains a set of configuration about Notifications
	/// </summary>
	[Serializable]
	public class NotificationConfiguration : DomainEntity {
		internal NotificationConfiguration ( ) {}

		/// <summary>
		/// Gets or sets a value indicating whether [notify new comment].
		/// </summary>
		/// <value><c>true</c> if [notify new comment]; otherwise, <c>false</c>.</value>
		public bool NotifyNewComment { get; set; }

		/// <summary>
		/// Gets or sets a value indicating whether [notify new trackback].
		/// </summary>
		/// <value><c>true</c> if [notify new trackback]; otherwise, <c>false</c>.</value>
		public bool NotifyNewTrackback { get; set; }

		public string SenderEmailString { get; set; }
		public string SenderEmailDisplayName { get; set; }

		[NonSerialized]
		MailAddress senderEmail;

		[XmlIgnore]
		public MailAddress SenderEmail {
			get {
				return senderEmail ?? ( senderEmail = !string.IsNullOrEmpty ( SenderEmailDisplayName )
				                                      	? new MailAddress ( SenderEmailString , SenderEmailDisplayName )
				                                      	: new MailAddress ( SenderEmailString ) );
			}
			set {
				senderEmail = value;
				SenderEmailString = senderEmail.Address;
				SenderEmailDisplayName = senderEmail.DisplayName;
			}
		}

		/// <summary>
		/// Gets or sets the notification email address.
		/// </summary>
		/// <value>The notification email address.</value>
		public string NotificationEmailAddress { get; set; }
	}
}
